package com.ltkj.shop.controller.mobile;

import com.ltkj.common.core.domain.R;
import com.ltkj.common.core.utils.bean.BeanUtils;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.web.page.TableDataInfo;
import com.ltkj.shop.domain.ShopHotel;
import com.ltkj.shop.domain.vo.ShopHotelVo;
import com.ltkj.shop.service.IShopHotelService;
import com.ltkj.system.api.domain.ShopHotelDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 酒店商户移动端接口Controller
 * 
 * @author xupf
 * @date 2023-08-29
 */
@Api(tags = "酒店商户移动端接口")
@RestController
@RequestMapping("/mobile/hotel")
public class ShopHotelMobileController extends BaseController
{
    @Autowired
    private IShopHotelService shopHotelService;

    /**
     * 查询酒店商户列表
     */
    @ApiOperation("查询酒店商户列表")
    @GetMapping("/list")
    public TableDataInfo list(ShopHotel shopHotel)
    {
        startPage();
        List<ShopHotelVo> list = shopHotelService.selectList(shopHotel);
        return getDataTable(list);
    }

    /**
     * 获取酒店商户详细信息
     */
    @ApiOperation("获取酒店商户详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopHotelService.selectShopHotelById(id));
    }

    /**
     * 首页综合推荐查询文创商品列表
     */
    @ApiOperation("首页综合推荐查询文创商品列表")
    @RequestMapping("/listTop")
    public R<List<ShopHotelDTO>> listTop(@RequestBody ShopHotelDTO shopHotelDTO)
    {
        ShopHotel shopHotel = new ShopHotel();
        BeanUtils.copyBeanProp(shopHotel, shopHotelDTO);
        List<ShopHotelVo> list = shopHotelService.selectList(shopHotel);
        return R.ok(list.stream().map(ShopHotelVo::toDTO).collect(Collectors.toList()));
    }
}
